<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Classroom</title>
</head>

<body>

<?php

//get variables passed from index.php
$classroom_id = $_GET['id'];
$building_id = $_GET['bid'];
$building_name = $_GET['name'];
$abbreviation = $_GET['abbrev'];
$room_num = $_GET['room_num'];
$num_seats = $_GET['num_seats'];
$description = $_GET['type'];




echo "<h1>UNO Course Scheduler - Edit Classroom in $building_name</h1>";



//initialize variables used to connect to database
$db = "scheduler";
$user = "root";
$pass = "";

//connect to database
mysql_connect("localhost", $user, $pass);
@mysql_select_db($db);

$query = "SELECT * FROM classroom_types WHERE description='$description'";
$result = mysql_query($query);
$classroom_type_id = mysql_result($result,0,"id");

//select statement
$query2="UPDATE classrooms 
SET room_num='$room_num', num_seats='$num_seats', classroom_type_id='$classroom_type_id'
WHERE id='$classroom_id'";

$result2=mysql_query($query2);

//close
mysql_close();

if ($result2)
{
	echo "<b>$abbreviation $room_num</b> has been successfully updated!";
	echo "<br />";
}
else
{
	echo "<b>$abbreviation $room_num</b> was NOT able to be updated!";
	echo "<br />";
}

echo "<p>";
	echo "<a href='index.php?id=$building_id&name=$building_name&abbrev=$abbreviation'>&lt;&lt; Back to Classrooms Portal</a><br />";
echo "</p>";
?>

</body>
</html>